<?php

class WikiNote extends Article {

	var $id_wikinote;
	var $title;
	var $description;
	
	/////////////////////////////////////////////////
	// Static member methods
	
	function WikiNote($id_wikinote = -1) {
		global $site;
		$this->_table_name = "articles";
		$this->_site = $site;
		$this->_object_type = "wikinote";
		$this->_db = new mysqlconn(HOST,USER,PASS,DB);
		$this->_meta_fields = array();
		$this->_alias_fields = array("id_article" => "id_wikinote", "title" => "title", "content" => "description");

		if ($id_wikinote != -1) {
			$this->load($id_wikinote);
		}
	}
	
	function create($title, $description, $kind) {
		$wikinote = new WikiNote();
		$wikinote->title = $title;
		$wikinote->description = $description;
		$wikinote->kind = $kind;
		return $wikinote->save();
	}

	//////////////////////////////////////////////////////////////////////////////
	// Instance member methods
	function get_sons() {
	
		// If sons is not loaded, bring it forth from the DB
		if (!$this->sons) {
			
			$this->sons = array();
			
			$this->_db->query(
				"SELECT
					id_article
				FROM
					".PREFIX."articles
				WHERE
					id_parent = '?'",
					$this->id_article);
			while ($a = $this->_db->getfield()) {
				array_push($this->sons, new Article($a));
			}
		}
		
		return $this->sons;
	}
	
	///////////////////////////////////////////////////////////////////////////////
	// Polymorphism methods
	function get_instance($id_instance) {
		return new WikiNote($id_instance);
	}

	
}

?>